<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<%@ include file="../common.jsp"%>
<%@ page import="org.springside.core.Constants"%>
<%@ page import="cn.firstsoft.firstframe.admin.*"%>
<%@ page import="java.util.Calendar,java.util.regex.Matcher,java.util.regex.Pattern"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>管理控制台 - 服务信息</title>
<%@ include file="/common/meta2.jsp"%>
<link href="../style.css" type="text/css" rel=stylesheet>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" background="#FFFFFF" onload="springsideShow();firstsoftShow();">

<script language="javascript">
function firstsoftShow() {
  var obj = document.log4j.firstsoft;
  if (obj.value=="1") {
    document.getElementById('firstsoftDetail').style.display = "";
  } else {
    document.getElementById('firstsoftDetail').style.display = "none";
  }
}
function springsideShow() {
  var obj = document.log4j.springside;
  if (obj.value=="1") {
    document.getElementById('springsideDetail').style.display = "";
  } else {
    document.getElementById('springsideDetail').style.display = "none";
  }
}  

function dbchange(){
  var obj = document.log4j.dbtype;
  if (obj.value=="oracle") {
    document.log4j.port.value = "1521";
  } else if (obj.value=="sqlserver") {
    document.log4j.port.value = "1433";
  }
}
function checkdata() {
    if (document.log4j.ip.value == "") {
		alert("数据库IP地址必须填写！");
		return false;
	}
	re=/(\d+)\.(\d+)\.(\d+)\.(\d+)/g ;
	if(!(re.exec(document.log4j.ip.value))){
	    alert("数据库IP地址不合法！");
		return false;
	}
	if (document.log4j.port.value == "") {
		alert("数据库端口号必须填写！");
		return false;
	}
	if (document.log4j.serverName.value == "") {
		alert("数据库名称必须填写！");
		return false;
	}
	if (document.log4j.dbuser.value == "") {
		alert("数据库用户名必须填写！");
		return false;
	}
	return true;
}
</script>
<%
  LogFileBean lfb = new LogFileBean();
  lfb.load();
%>
<FORM name="log4j" method="post" action="logger_log4j_update.jsp">

	<input class=button type=button value="提&nbsp;&nbsp;交" onClick="if (checkdata()) { this.form.submit(); } else { return false; }" />
	<input class=button type=reset value="重&nbsp;&nbsp;置" />
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
  <TBODY>
	<TR>
		<TD class=listViewPaginationTdS1 colSpan=20>
		Log4j.properties属性设置

		</TD>
	</TR>

	<TR>
	    <TD class=tabDetailViewDL vAlign=top width="25%">
	    log4j.rootCategory:&nbsp;
	    </TD>
	    <TD class=tabDetailViewDF vAlign=top width="75%">
<%
out.println(lfb.getRootCategory());
%>
	    </TD>
	</TR>

	<TR>
	    <TD class=tabDetailViewDL vAlign=top width="25%">
	    log4j.logger.cn.firstsoft.modules:&nbsp;
	    </TD>
	    <TD class=tabDetailViewDF vAlign=top width="75%">
<%
boolean modulesFlag = false;
if(lfb.getLoggerFirstsoft()==null || "".equals(lfb.getLoggerFirstsoft())){
  modulesFlag = false;
} else {
  modulesFlag = true;
}

%>
<table >
  <tr>
   <td>
      <select name = "firstsoft" onchange="firstsoftShow();">
      <option value="1" <% if (modulesFlag) out.println("selected"); %>>启用</option>
      <option value="0" <% if (!modulesFlag) out.println("selected"); %>>禁用</option>
    </select>
   </td>
   <td id="firstsoftDetail" Style="Display:none">
      <input type="checkbox" name="firstsoftCheckBox" value="stdout" <%if (lfb.getLoggerFirstsoft()!=null && lfb.getLoggerFirstsoft().toLowerCase().indexOf("stdout")>0) out.println("checked");%>>stdout
      <input type="checkbox" name="firstsoftCheckBox" value="security" <%if (lfb.getLoggerFirstsoft()!=null && lfb.getLoggerFirstsoft().toLowerCase().indexOf("security")>0) out.println("checked");%>>security
      <input type="checkbox" name="firstsoftCheckBox" value="logfile" <%if (lfb.getLoggerFirstsoft()!=null && lfb.getLoggerFirstsoft().toLowerCase().indexOf("logfile")>0) out.println("checked");%>>logfile
      <input type="checkbox" name="firstsoftCheckBox" value="operationfile" <%if (lfb.getLoggerFirstsoft()!=null && lfb.getLoggerFirstsoft().toLowerCase().indexOf("operationfile")>0) out.println("checked");%>>operationfile
      <input type="checkbox" name="firstsoftCheckBox" value="db" <%if (lfb.getLoggerFirstsoft()!=null && lfb.getLoggerFirstsoft().toLowerCase().indexOf("db")>0) out.println("checked");%>>db
   </td>
  </tr>
</table>
	    </TD>
	</TR>

	<TR>
	    <TD class=tabDetailViewDL vAlign=top width="25%">
	    log4j.logger.org.springside.modules:&nbsp;
	    </TD>
	    <TD class=tabDetailViewDF vAlign=top width="75%">
<%
boolean springsideFlag = false;
if(lfb.getLoggerSpringside()==null || "".equals(lfb.getLoggerSpringside())){
  springsideFlag = false;
} else {
  springsideFlag = true;
}
%>
<table >
  <tr>
   <td>
<select name = "springside" onchange="springsideShow();">
  <option value="1" <% if (springsideFlag) out.println("selected"); %>>启用</option>
  <option value="0" <% if (!springsideFlag) out.println("selected"); %>>禁用</option>
</select>
   </td>
   <td id="springsideDetail" Style="Display:none">
      <input type="checkbox" name="springsideCheckBox" value="stdout" <%if (lfb.getLoggerSpringside()!=null && lfb.getLoggerSpringside().toLowerCase().indexOf("stdout")>0) out.println("checked");%>>stdout
      <input type="checkbox" name="springsideCheckBox" value="security" <%if (lfb.getLoggerSpringside()!=null && lfb.getLoggerSpringside().toLowerCase().indexOf("security")>0) out.println("checked");%>>security
      <input type="checkbox" name="springsideCheckBox" value="logfile" <%if (lfb.getLoggerSpringside()!=null && lfb.getLoggerSpringside().toLowerCase().indexOf("logfile")>0) out.println("checked");%>>logfile
      <input type="checkbox" name="springsideCheckBox" value="operationfile" <%if (lfb.getLoggerSpringside()!=null && lfb.getLoggerSpringside().toLowerCase().indexOf("operationfile")>0) out.println("checked");%>>operationfile
      <input type="checkbox" name="springsideCheckBox" value="db" <%if (lfb.getLoggerSpringside()!=null && lfb.getLoggerSpringside().toLowerCase().indexOf("db")>0) out.println("checked");%>>db
   </td>
  </tr>
</table>
	    </TD>
	</TR>
	<TR>
		<TD class=listViewPaginationTdS1 colSpan=20>
		db属性设置

		</TD>
	</TR>
	<TR>
	    <TD class=tabDetailViewDL vAlign=top width="25%">
	    log4j.appender.db:&nbsp;
	    </TD>
	    <TD class=tabDetailViewDF vAlign=top width="75%">
<%
out.println(lfb.getDB().getName());
%>
	    </TD>
	</TR>
	<TR>
	    <TD class=tabDetailViewDL vAlign=top width="25%">
	    数据库类型:&nbsp;
	    </TD>
	    <TD class=tabDetailViewDF vAlign=top width="75%">
<select name = "dbtype" onchange="dbchange();">
  <option value="oracle" <%if (lfb.getDB().getURL()!=null && lfb.getDB().getURL().toLowerCase().indexOf("oracle")>-1) out.println("selected");%>>oracle</option>
  <option value="sqlserver" <%if (lfb.getDB().getURL()!=null && lfb.getDB().getURL().toLowerCase().indexOf("sqlserver")>-1) out.println("selected");%>>sql server</option>
</select>
	    </TD>
	</TR>
	<TR>
	    <TD class=tabDetailViewDL vAlign=top width="25%">
	    log4j.appender.db.BufferSize:&nbsp;
	    </TD>
	    <TD class=tabDetailViewDF vAlign=top width="75%">
<%
out.println(lfb.getDB().getBufferSize());
%>
	    </TD>
	</TR>

	<TR>
	    <TD class=tabDetailViewDL vAlign=top width="25%">
	    log4j.appender.db.URL:&nbsp;
	    </TD>
	    <TD class=tabDetailViewDF vAlign=top width="75%">
<%
out.println(lfb.getDB().getURL());

String ip = "";
String port = "";
String databaseName = "";

if (lfb.getDB().getURL()!=null && lfb.getDB().getURL().toLowerCase().indexOf("oracle")>-1) {
        String t = "jdbc:oracle:thin:@(.*?):(\\d*?):(.*?)\\s*?$";
        String s=lfb.getDB().getURL();
		Pattern p=Pattern.compile(t);
		Matcher m=p.matcher(s);
		while(m.find()){
			ip = m.group(1);
			port = m.group(2);
			databaseName = m.group(3);
		}
} else if (lfb.getDB().getURL()!=null && lfb.getDB().getURL().toLowerCase().indexOf("sqlserver")>-1) {
        String t = "jdbc:jtds:sqlserver:\\/\\/(.*?):(\\d*?);.*?\\=([a-zA-Z]{1}\\w*)\\s*?$";
        String s=lfb.getDB().getURL();
		Pattern p=Pattern.compile(t);
		Matcher m=p.matcher(s);
		
		while(m.find()){
			ip = m.group(1);
			port = m.group(2);
			databaseName = m.group(3);
		}
}
//jdbc:oracle:thin:@localhost:1521:orcl
//jdbc:jtds:sqlserver://192.168.1.144:1433;DatabaseName=firstframe 

%>
	    </TD>
	</TR>
	<TR>
	    <TD class=tabDetailViewDL vAlign=top width="25%">
	    数据库地址:&nbsp;
	    </TD>
	    <TD class=tabDetailViewDF vAlign=top width="75%">
<input type="text" name="ip" value="<%=ip%>">
	    </TD>
	</TR>
	<TR>
	    <TD class=tabDetailViewDL vAlign=top width="25%">
	    端口号:&nbsp;
	    </TD>
	    <TD class=tabDetailViewDF vAlign=top width="75%">
<input type="text" name="port" value="<%=port%>" onkeyup="value=value.replace(/[^\d]/g,'') "onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))">
	    </TD>
	</TR>
	<TR>
	    <TD class=tabDetailViewDL vAlign=top width="25%">
	    数据库名/SID:&nbsp;
	    </TD>
	    <TD class=tabDetailViewDF vAlign=top width="75%">
<input type="text" name="serverName" value="<%=databaseName%>">
	    </TD>
	</TR>
	<TR>
	    <TD class=tabDetailViewDL vAlign=top width="25%">
	    log4j.appender.db.user:&nbsp;
	    </TD>
	    <TD class=tabDetailViewDF vAlign=top width="75%">
<input type="text" name="dbuser" value="<%=lfb.getDB().getUser()%>">
	    </TD>
	</TR>

	<TR>
	    <TD class=tabDetailViewDL vAlign=top width="25%">
	    log4j.appender.db.password:&nbsp;
	    </TD>
	    <TD class=tabDetailViewDF vAlign=top width="75%">
<input type="text" name="dbpassword" value="<%=lfb.getDB().getPassword()%>">
	    </TD>
	</TR>
	<TR>
	    <TD class=tabDetailViewDL vAlign=top width="25%">
	    log4j.appender.db.driver:&nbsp;
	    </TD>
	    <TD class=tabDetailViewDF vAlign=top width="75%">
<%
out.println(lfb.getDB().getDriver());
%>
	    </TD>
	</TR>



	<TR>
	    <TD class=tabDetailViewDL vAlign=top width="25%">
	    log4j.appender.db.sql:&nbsp;
	    </TD>
	    <TD class=tabDetailViewDF vAlign=top width="75%">
<%
out.println(lfb.getDB().getSql());
%>
	    </TD>
	</TR>

	<TR>
	    <TD class=tabDetailViewDL vAlign=top width="25%">
	    log4j.appender.db.layout:&nbsp;
	    </TD>
	    <TD class=tabDetailViewDF vAlign=top width="75%">
<%
out.println(lfb.getDB().getLayout());
%>
	    </TD>
	</TR>
	<TR>
		<TD class=listViewPaginationTdS1 colSpan=20>
		security属性设置

		</TD>
	</TR>

	<TR>
	    <TD class=tabDetailViewDL vAlign=top width="25%">
	    log4j.appender.security:&nbsp;
	    </TD>
	    <TD class=tabDetailViewDF vAlign=top width="75%">
<%
out.println(lfb.getSecurity().getName());
%>
	    </TD>
	</TR>

	<TR>
	    <TD class=tabDetailViewDL vAlign=top width="25%">
	    log4j.appender.security.File:&nbsp;
	    </TD>
	    <TD class=tabDetailViewDF vAlign=top width="75%">
<%
out.println(lfb.getSecurity().getFile());
%>
	    </TD>
	</TR>

	<TR>
	    <TD class=tabDetailViewDL vAlign=top width="25%">
	    log4j.appender.security.MaxFileSize:&nbsp;
	    </TD>
	    <TD class=tabDetailViewDF vAlign=top width="75%">
<%
out.println(lfb.getSecurity().getMaxFileSize());
%>
	    </TD>
	</TR>

	<TR>
	    <TD class=tabDetailViewDL vAlign=top width="25%">
	    log4j.appender.security.MaxBackupIndex:&nbsp;
	    </TD>
	    <TD class=tabDetailViewDF vAlign=top width="75%">
<%
out.println(lfb.getSecurity().getMaxBackupIndex());
%>
	    </TD>
	</TR>

	<TR>
	    <TD class=tabDetailViewDL vAlign=top width="25%">
	    log4j.appender.security.layout:&nbsp;
	    </TD>
	    <TD class=tabDetailViewDF vAlign=top width="75%">
<%
out.println(lfb.getSecurity().getLayout());
%>
	    </TD>
	</TR>

	<TR>
	    <TD class=tabDetailViewDL vAlign=top width="25%">
	    log4j.appender.security.layout.conversionPattern:&nbsp;
	    </TD>
	    <TD class=tabDetailViewDF vAlign=top width="75%">
<%
out.println(lfb.getSecurity().getConversionPattern());
%>
	    </TD>
	</TR>
	<TR>
		<TD class=listViewPaginationTdS1 colSpan=20>
		stdout属性设置

		</TD>
	</TR>
	<TR>
	    <TD class=tabDetailViewDL vAlign=top width="25%">
	    log4j.appender.stdout:&nbsp;
	    </TD>
	    <TD class=tabDetailViewDF vAlign=top width="75%">
<%
out.println(lfb.getStdout().getName());
%>
	    </TD>
	</TR>

	<TR>
	    <TD class=tabDetailViewDL vAlign=top width="25%">
	    log4j.appender.stdout.layout:&nbsp;
	    </TD>
	    <TD class=tabDetailViewDF vAlign=top width="75%">
<%
out.println(lfb.getStdout().getLayout());
%>
	    </TD>
	</TR>

	<TR>
	    <TD class=tabDetailViewDL vAlign=top width="25%">
	    log4j.appender.stdout.layout.ConversionPattern:&nbsp;
	    </TD>
	    <TD class=tabDetailViewDF vAlign=top width="75%">
<%
out.println(lfb.getStdout().getConversionPattern());
%>
	    </TD>
	</TR>
	<TR>
		<TD class=listViewPaginationTdS1 colSpan=20>
		logfile属性设置

		</TD>
	</TR>
	<TR>
	    <TD class=tabDetailViewDL vAlign=top width="25%">
	    log4j.appender.logfile:&nbsp;
	    </TD>
	    <TD class=tabDetailViewDF vAlign=top width="75%">
<%
out.println(lfb.getLogfile().getName());
%>
	    </TD>
	</TR>

	<TR>
	    <TD class=tabDetailViewDL vAlign=top width="25%">
	    log4j.appender.logfile.File:&nbsp;
	    </TD>
	    <TD class=tabDetailViewDF vAlign=top width="75%">
<%
out.println(lfb.getLogfile().getFile());
%>
	    </TD>
	</TR>

	<TR>
	    <TD class=tabDetailViewDL vAlign=top width="25%">
	    log4j.appender.logfile.MaxFileSize:&nbsp;
	    </TD>
	    <TD class=tabDetailViewDF vAlign=top width="75%">
<%
out.println(lfb.getLogfile().getMaxFileSize());
%>
	    </TD>
	</TR>

	<TR>
	    <TD class=tabDetailViewDL vAlign=top width="25%">
	    log4j.appender.logfile.MaxBackupIndex:&nbsp;
	    </TD>
	    <TD class=tabDetailViewDF vAlign=top width="75%">
<%
out.println(lfb.getLogfile().getMaxBackupIndex());
%>
	    </TD>
	</TR>

	<TR>
	    <TD class=tabDetailViewDL vAlign=top width="25%">
	    log4j.appender.logfile.layout:&nbsp;
	    </TD>
	    <TD class=tabDetailViewDF vAlign=top width="75%">
<%
out.println(lfb.getLogfile().getLayout());
%>
	    </TD>
	</TR>

	<TR>
	    <TD class=tabDetailViewDL vAlign=top width="25%">
	    log4j.appender.logfile.layout.ConversionPattern:&nbsp;
	    </TD>
	    <TD class=tabDetailViewDF vAlign=top width="75%">
<%
out.println(lfb.getLogfile().getConversionPattern());
%>
	    </TD>
	</TR>
	<TR>
		<TD class=listViewPaginationTdS1 colSpan=20>
		operationfile属性设置

		</TD>
	</TR>
	<TR>
	    <TD class=tabDetailViewDL vAlign=top width="25%">
	    log4j.appender.operationfile:&nbsp;
	    </TD>
	    <TD class=tabDetailViewDF vAlign=top width="75%">
<%
out.println(lfb.getOperationfile().getName());
%>
	    </TD>
	</TR>

	<TR>
	    <TD class=tabDetailViewDL vAlign=top width="25%">
	    log4j.appender.operationfile.File:&nbsp;
	    </TD>
	    <TD class=tabDetailViewDF vAlign=top width="75%">
<%
out.println(lfb.getOperationfile().getFile());
%>
	    </TD>
	</TR>

	<TR>
	    <TD class=tabDetailViewDL vAlign=top width="25%">
	    log4j.appender.operationfile.MaxFileSize:&nbsp;
	    </TD>
	    <TD class=tabDetailViewDF vAlign=top width="75%">
<%
out.println(lfb.getOperationfile().getMaxFileSize());
%>
	    </TD>
	</TR>

	<TR>
	    <TD class=tabDetailViewDL vAlign=top width="25%">
	    log4j.appender.operationfile.MaxBackupIndex:&nbsp;
	    </TD>
	    <TD class=tabDetailViewDF vAlign=top width="75%">
<%
out.println(lfb.getOperationfile().getMaxBackupIndex());
%>
	    </TD>
	</TR>

	<TR>
	    <TD class=tabDetailViewDL vAlign=top width="25%">
	    log4j.appender.operationfile.layout:&nbsp;
	    </TD>
	    <TD class=tabDetailViewDF vAlign=top width="75%">
<%
out.println(lfb.getOperationfile().getLayout());
%>
	    </TD>
	</TR>

	<TR>
	    <TD class=tabDetailViewDL vAlign=top width="25%">
	    log4j.appender.operationfile.layout.ConversionPattern:&nbsp;
	    </TD>
	    <TD class=tabDetailViewDF vAlign=top width="75%">
<%
out.println(lfb.getOperationfile().getConversionPattern());
%>
	    </TD>
	</TR>


	
	</TBODY>
</TABLE>
</FORM>
</body>
</html>